define(["jquery","template",
	"scprit/nutrition/app/foodLibrary/editFood.servers.js",
	"scprit/nutrition/template/foodLibrary/editFood.tpl.js"],
	function($,template,$servers,tpl){
	var ui = {};

	var drawFoodLibirayTab = function(data){
    	return template("editFood_foodLibirayTab",data);
    }
    var drawFoodMenus = function(data){
        return template("editFood_foodMenus",data);
    }
  /*  var drawNutrientList = function(data){
    	return template("editFood_nutrientList",data);
    }*/
    var drawNutrientList2 = function(data){
        return template("editFood_nutrientList2",data);
    }
    var drawNutrientListAppend = function(data){
        return template("editFood_nutrientListAppend",data);
    }
    var drawNutrientUnit = function(data){
        return template("editFood_nutrientUnit",data);
    }
    var drawContextMenu = function(data){
        return template("editFood_contextMenu",data);
    }
    var drawModifyFoodClassifyForm = function(data){
        return template("editFood_modifyFoodClassifyForm",data);
    }
    var drawEditFoodBox = function(data){
        return template("editFood_editFoodBox",data);
    }

	ui.foodLibirayTabInit = function(options){
    	$("#" + options.id).html( tpl.foodLibirayTab() );
        var html = drawFoodLibirayTab($servers.handleFoodLibirayTab(options));
        $("#" + options.id).html(html);
    }
    ui.foodMenusInit = function(options){
        $("#" + options.id).html( tpl.foodMenus() );
        var html = drawFoodMenus(options);
        $("#" + options.id).html(html);
    }
   /* ui.nutrientListInit = function(options){
    	options.dom1.html( tpl.nutrientList() );
        options.dom2.html( tpl.nutrientUnit() );
        var h1 = drawNutrientList(options);
        var h2 = drawNutrientUnit(options);
        options.dom1.html(h1);
        options.dom2.html(h2);
    }*/
    ui.nutrientListInit2 = function(options){
        $(options.id).html( tpl.nutrientList2() );
        var html = drawNutrientList2(options);
        $(options.id).html( html );
    }
    ui.nutrientListAppendInit = function(options){
        $(options.dom).append( tpl.nutrientListAppend() );
        var html = drawNutrientListAppend(options);console.log(html);
        $(options.dom).append( html );
    }
    ui.contextMenu = function(options){
        $("#" + options.id).html( tpl.contextMenu() );
        var html = drawContextMenu(options);
        $("#" + options.id).html(html);
    }
    ui.modifyFoodClassifyFormInit = function(options){
        options.dom.html( tpl.modifyFoodClassifyForm() );
        var html = drawModifyFoodClassifyForm(options);
        options.dom.html(html);
    }
    ui.editFoodBoxInit = function(options){
        $("#" + options.id).html( tpl.editFoodBox() );
        var html = drawEditFoodBox(options);
        $("#" + options.id).html(html);
    }
    

	return ui;
});